package com.service.device;

import com.dao.secondary.device.DevicePcbVersionInfoMapper;
import com.dao.secondary.device.DevicePmdVersionInfoMapper;
import com.github.pagehelper.PageHelper;
import com.model.domain.device.GetDevicePcbVersionInfoDO;
import com.model.domain.device.GetDevicePmdVersionInfoDO;
import com.model.pojo.device.DevicePcbVersionInfo;
import com.model.pojo.device.DevicePmdVersionInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


/**
 * @Author: zql
 * @Description: PMD播种机版本号信息管理服务
 * @Data: 2023-07-16
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class DevicePcbVersionInfoService {
    private final DevicePcbVersionInfoMapper devicePcbVersionInfoMapper;

    public List<DevicePcbVersionInfo> getPageList(GetDevicePcbVersionInfoDO getDevicePcbVersionInfoDO){
        PageHelper.clearPage();
        PageHelper.startPage(getDevicePcbVersionInfoDO.getPage(),getDevicePcbVersionInfoDO.getPageSize(),getDevicePcbVersionInfoDO.getSortRow()+getDevicePcbVersionInfoDO.getSortOrder());
        return devicePcbVersionInfoMapper.selectList(getDevicePcbVersionInfoDO);
    }

    public int save(DevicePcbVersionInfo info){
        info.setCreateTime(new Date());
        return devicePcbVersionInfoMapper.insertSelective(info);
    }
    public int update(DevicePcbVersionInfo info){
        return devicePcbVersionInfoMapper.updateByPrimaryKeySelective(info);
    }

    public void delete(Long id){
        devicePcbVersionInfoMapper.deleteByPrimaryKey(id);
    }
    public DevicePcbVersionInfo getById(Long id){
        return devicePcbVersionInfoMapper.selectByPrimaryKey(id);
    }
}
